/*var vm = new Vue({
	el:'#rrapp',
	data:{	
		user:{},
		showList:true	
	},
	methods: {	
		getUser: function(){
			$.getJSON("../sys/user/info?_"+$.now(), function(r){
				vm.user = r.user;
				var name=vm.user.username;
				$.post("../sys/user/rolename", {name: name},
						function(data){
					
					if(data==="\"普通员工\""){						
						vm.showList=false;						
					}
				})
				
			});
		}
	},
	created: function () {
		this.getUser();
	}
	
});
*/
$(function(){
	getUser()
})
function getUser(){
			$.getJSON("../sys/user/info?_"+$.now(), function(r){
				var name = r.user.username;
				$.post("../sys/user/rolename", {name: name},
						function(data){
					
					if(data==="\"普通员工\""){						
						$("#show").css('display','none')						
					}
				})
				
			});
		}
function hisone(){
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#hisTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			var formData = {
					"time":$("#inorgtime4").val()
			}
			$.ajax({
				url : '../hisemployee/toHisEnd',
				type : 'POST',
				async : false,
				data : formData,
				success: function(r){
					r=JSON.parse(r);
					if(r.code==0){
						layer.alert("存入成功",function(index){
							location.reload();
							layer.close(index);
						});      
					}else{
						layer.alert(r.msg);
					}
				}
			});
			layer.close(indexout);
		}
	});





	/*layer.confirm("存入历史将不可改动",function(index){
		$.ajax({
			type: "GET",
		    url: '../dictdepartment/tohis',
		    data:"time="+time,
		    success: function(r){
		    	if(r.code === 0){
		    		alert("存入成功");
		    	}else{
			    		alert("存入错误");
				}
			}
		});
	});*/
}
/*
function surehis(){
		$("#time").hide();
		$("#sure").hide();	
		var time = $("#time").val();
		if(time==""){
			alert("请选择时间");				
		}else{
			$.ajax({
				type: "GET",
			    url: '../dictdepartment/hashis',
			    data:"time="+time,
			    success: function(r){
			    	if(r.code === 0){
			    		confirm("该月份已有历史，是否要覆盖",function(){
			    			$.ajax({
			    				type: "GET",
			    			    url: '../dictdepartment/tohis',
			    			    data:"time="+time,
			    			    success: function(r){
			    			    	if(r.code === 0){
			    			    		alert("存入成功");
			    			    	}else{
			    				    		alert("存入错误");
			    					}
			    				}
			    			});
			    		});
			    	}else{
			    		$.ajax({
		    				type: "GET",
		    			    url: '../dictdepartment/tohis',
		    			    data:"time="+time,
		    			    success: function(r){
		    			    	if(r.code === 0){
		    			    		alert("存入成功");
		    			    	}else{
		    				    		alert("存入错误");
		    					}
		    				}
		    			});
					}
				}
			});

		}	

}*/

function imp1(){
	$("#uploadFile1").click();
	$("#sureup1").show();
}
function up1() {
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#zzjgTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			$("#sureup1").hide();
			var uploadFile1 = document.getElementById("uploadFile1").value;      
			if(uploadFile1 == null || uploadFile1 == ''){      
				layer.alert("请选择要上传的Excel文件");      
				return;      
			}else{      
				var fileExtend = uploadFile1.substring(uploadFile1.lastIndexOf('.')).toLowerCase();       
				if(fileExtend == '.xls'||fileExtend == '.xlsx'){    
					var formData = new FormData();
					var name = $("#uploadFile1").val();
					formData.append("file",$("#uploadFile1")[0].files[0]);
					formData.append("time",$("#inorgtime1").val());
					var indexing = layer.load(1);
					$.ajax({
						url : '../dictdepartment/upload',
						type : 'POST',
						async : false,
						data : formData,
						// 告诉jQuery不要去处理发送的数据
						processData : false,
						// 告诉jQuery不要去设置Content-Type请求头
						contentType : false,
						beforeSend:function(){
							//console.log("正在进行，请稍候");
						},
						success : function(r) {
							r=JSON.parse(r);
							if(r.code==0){
								layer.close(indexing);
								layer.alert("导入成功",function(index){
									location.reload();
									layer.close(index);
								});      
							}else{
								layer.close(indexing);
								layer.alert(r.msg);

							}
						}
					});
				}else{      
					layer.alert("文件格式需为'.xls'格式");      
					return;      
				}      
			}  
			layer.close(indexout);
		}
	});

	//提交表单       
}


function imp2(){
	$("#uploadFile2").click();
	$("#sureup2").show();
}
function up2() {
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#ygTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			$("#sureup2").hide();
			var uploadFile2 = document.getElementById("uploadFile2").value;      
			if(uploadFile2 == null || uploadFile2 == ''){      
				layer.alert("请选择要上传的Excel文件");      
				return;      
			}else{      
				var fileExtend = uploadFile2.substring(uploadFile2.lastIndexOf('.')).toLowerCase();       
				if(fileExtend == '.xls'||fileExtend == '.xlsx'){    
					var formData = new FormData();
					var name = $("#uploadFile2").val();
					formData.append("file",$("#uploadFile2")[0].files[0]);
					formData.append("time",$("#inorgtime2").val());
					var indexing = layer.load(1);
					$.ajax({
						url : '../dictemployee/upload',
						type : 'POST',
						async : false,
						data : formData,
						// 告诉jQuery不要去处理发送的数据
						processData : false,
						// 告诉jQuery不要去设置Content-Type请求头
						contentType : false,
						beforeSend:function(){
							//console.log("正在进行，请稍候");
						},
						success : function(r) {
							r=JSON.parse(r);
							if(r.code==0){
								layer.close(indexing);
								layer.alert("导入成功",function(index){
									location.reload();
									layer.close(index);
								});      
							}else{
								layer.close(indexing);
								layer.alert(r.msg);

							}
						}
					});
				}else{      
					layer.alert("文件格式需为'.xls'格式");      
					return;      
				}      
			}  
			layer.close(indexout);
		}
	});

	//提交表单       
}



function imp3(){
	$("#uploadFile3").click();
	$("#sureup3").show();
}
function up3() {
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#htTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			$("#sureup3").hide();
			var uploadFile3 = document.getElementById("uploadFile3").value;      
			if(uploadFile3 == null || uploadFile3 == ''){      
				layer.alert("请选择要上传的Excel文件");      
				return;      
			}else{      
				var fileExtend = uploadFile3.substring(uploadFile3.lastIndexOf('.')).toLowerCase();       
				if(fileExtend == '.xls'||fileExtend == '.xlsx'){    
					var formData = new FormData();
					var name = $("#uploadFile3").val();
					formData.append("file",$("#uploadFile3")[0].files[0]);
					formData.append("time",$("#inorgtime3").val());
					var indexing = layer.load(1);
					$.ajax({
						url : '../datacontract/upload',
						type : 'POST',
						async : false,
						data : formData,
						// 告诉jQuery不要去处理发送的数据
						processData : false,
						// 告诉jQuery不要去设置Content-Type请求头
						contentType : false,
						beforeSend:function(){
							//console.log("正在进行，请稍候");
						},
						success : function(r) {
							r=JSON.parse(r);
							if(r.code==0){
								layer.close(indexing);
								layer.alert("导入成功",function(index){
									location.reload();
									layer.close(index);
								});      
							}else{
								layer.close(indexing);
								layer.alert(r.msg);

							}
						}
					});
				}else{      
					layer.alert("文件格式需为'.xls'格式");      
					return;      
				}      
			}  
			layer.close(indexout);
		}
	});

	//提交表单       
}
function imp4(){
	$("#uploadFile4").click();
	$("#sureup4").show();
}
function up4() {
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#addTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			$("#sureup4").hide();
			var uploadFile1 = document.getElementById("uploadFile4").value;      
			if(uploadFile1 == null || uploadFile1 == ''){      
				layer.alert("请选择要上传的Excel文件");      
				return;      
			}else{      
				var fileExtend = uploadFile1.substring(uploadFile1.lastIndexOf('.')).toLowerCase();       
				if(fileExtend == '.xls'||fileExtend == '.xlsx'){    
					var formData = new FormData();
					var name = $("#uploadFile4").val();
					formData.append("file",$("#uploadFile4")[0].files[0]);
					formData.append("time",$("#inorgtimeadd").val());
					var indexing = layer.load(1);
					$.ajax({
						url : '../dataaddmoney/upload',
						type : 'POST',
						async : false,
						data : formData,
						// 告诉jQuery不要去处理发送的数据
						processData : false,
						// 告诉jQuery不要去设置Content-Type请求头
						contentType : false,
						beforeSend:function(){
							//console.log("正在进行，请稍候");
						},
						success : function(r) {
							r=JSON.parse(r);
							if(r.code==0){
								layer.close(indexing);
								layer.alert("导入成功",function(index){
									location.reload();
									layer.close(index);
								});      
							}else{
								layer.close(indexing);
								layer.alert(r.msg);

							}
						}
					});
				}else{      
					layer.alert("文件格式需为'.xls'格式");      
					return;      
				}      
			}  
			layer.close(indexout);
		}
	});

	//提交表单       
}function imp5(){
	$("#uploadFile5").click();
	$("#sureup5").show();
}
function up5() {
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#lostTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			$("#sureup5").hide();
			var uploadFile1 = document.getElementById("uploadFile5").value;      
			if(uploadFile1 == null || uploadFile1 == ''){      
				layer.alert("请选择要上传的Excel文件");      
				return;      
			}else{      
				var fileExtend = uploadFile1.substring(uploadFile1.lastIndexOf('.')).toLowerCase();       
				if(fileExtend == '.xls'||fileExtend == '.xlsx'){    
					var formData = new FormData();
					var name = $("#uploadFile5").val();
					formData.append("file",$("#uploadFile5")[0].files[0]);
					formData.append("time",$("#inorgtimelost").val());
					var indexing = layer.load(1);
					$.ajax({
						url : '../datalostmoney/upload',
						type : 'POST',
						async : false,
						data : formData,
						// 告诉jQuery不要去处理发送的数据
						processData : false,
						// 告诉jQuery不要去设置Content-Type请求头
						contentType : false,
						beforeSend:function(){
							//console.log("正在进行，请稍候");
						},
						success : function(r) {
							r=JSON.parse(r);
							if(r.code==0){
								layer.close(indexing);
								layer.alert("导入成功",function(index){
									location.reload();
									layer.close(index);
								});      
							}else{
								layer.close(indexing);
								layer.alert(r.msg);

							}
						}
					});
				}else{      
					layer.alert("文件格式需为'.xls'格式");      
					return;      
				}      
			}  
			layer.close(indexout);
		}
	});

	//提交表单       
}
function imp6(){
	$("#uploadFile6").click();
	$("#sureup6").show();
}
function up6() {
	layer.open({
		type : 1,
		title : "选择时间",
		// closeBtn : 0,
		area : [ "40%", "40%" ],
		// skin : 'layui-layer-nobg', // 没有背景色
		shadeClose : true,
		content : $('#calTime'),
		btn: ['确认', '取消'],
		yes : function(indexout,
				layero) {
			$("#sureup3").hide();
			var uploadFile3 = document.getElementById("uploadFile3").value;      
			if(uploadFile3 == null || uploadFile3 == ''){      
				layer.alert("请选择要上传的Excel文件");      
				return;      
			}else{      
				var fileExtend = uploadFile3.substring(uploadFile3.lastIndexOf('.')).toLowerCase();       
				if(fileExtend == '.xls'||fileExtend == '.xlsx'){    
					var formData = new FormData();
					var name = $("#uploadFile3").val();
					formData.append("file",$("#uploadFile3")[0].files[0]);
					formData.append("time",$("#inorgtime3").val());
					var indexing = layer.load(1);
					$.ajax({
						url : '../datacontract/upload',
						type : 'POST',
						async : false,
						data : formData,
						// 告诉jQuery不要去处理发送的数据
						processData : false,
						// 告诉jQuery不要去设置Content-Type请求头
						contentType : false,
						beforeSend:function(){
							//console.log("正在进行，请稍候");
						},
						success : function(r) {
							r=JSON.parse(r);
							if(r.code==0){
								layer.close(indexing);
								layer.alert("导入成功",function(index){
									location.reload();
									layer.close(index);
								});      
							}else{
								layer.close(indexing);
								layer.alert(r.msg);

							}
						}
					});
				}else{      
					layer.alert("文件格式需为'.xls'格式");      
					return;      
				}      
			}  
			layer.close(indexout);
		}
	});

	//提交表单       
}
function calculate(){	
    var days=$("#allDay").val();
	var time=$("#paytime").val();
	if(days==null||days==""){
		alert("请输入应出勤天数")
		return;
	}else{	
		
		$.ajax({
			url: "../datacontract/calculate",
			type: "post",
			async: true,
			data: {
				'days': days,
				"time":time,
				
			},
			beforeSend: function () {
		        // 禁用按钮防止重复提交
				document.getElementById("cal").style.display="none";
				document.getElementById("load").style.display="block";
		    },
			success: function (r) {
				var obj= eval("("+r+")");
				obj=jQuery.parseJSON(obj);
				document.getElementById("cal").style.display="inline";
				document.getElementById("load").style.display="none";
				alert(obj.result);
			}
		});
	}
	
}
function cancel(){
	var time=$("#canceltime").val();
	$.post("../datacontract/cancel/"+time,{async:false}, function(r){
		var obj= eval("("+r+")");
		obj=jQuery.parseJSON(obj);
		alert(obj.result)
	});
}
function deleteHis(){
	$.post("../datacontract/deleteHis",{async:false}, function(r){
		var obj= eval("("+r+")");
		obj=jQuery.parseJSON(obj);
		alert(obj.result)
	});
}
